var server = require('../../../utils/server');
Page({



data:{
		 
	 	array: [
	 	'原因1', 
	 	'原因2', 
	 	'原因3',
	 	'原因4',
	 	'原因5',
	 	'原因6',
	 	'原因7'
	 	 ],
		 
		reason:'', 
		order_id:'',
		yuanyin:'',
	},

	formSubmit: function(e) {

		var app = getApp();
		var user_id = app.globalData.userInfo.user_id;
		 
		 
		var reason = this.data.reason;
		var order_id = this.data.order_id;
		var yuanyin = this.data.yuanyin;
		var userid =this.globalData



		if (yuanyin==''||yuanyin==null) {
				wx.showToast({
					title: '请选择退货原因',
					duration: 2000
				});
				 return false;
		};
		if (reason==''||reason==null) {
				wx.showToast({
					title: '描述不能为空',
					duration: 2000
				});
				 return false;
		};
		 


		server.getJSON('/User/return_order',{user_id:user_id,order_id:order_id,yuanyin:yuanyin,reason:reason},function(res){
        		if(res.data.status==1){
        			wx.showToast({
						title: res.data.msg,
						duration: 2000
					});
        			  setTimeout(function () {
					wx.navigateTo({

						url: '../list/list'
					});
				}, 1000);

        		}else{

        			wx.showToast({
					title: res.data.msg,
					duration: 2000
				});
				 return false;

        		}




        		console.log(res.data.status==1);return false;
			// if(res.data.status == 1)
			// {
				wx.showToast({
					title: '保存成功',
					duration: 1000
				});

				if(that.data.returnTo == 1)
	            setTimeout(function () {
					wx.navigateTo({
						url: '../../order/ordersubmit/index'
					});
				}, 1000);
	            else
				{
					wx.navigateBack();
				}
			// }
		});


  
	},
		 



 bindPickerChange: function(e) {
 	 
	var index=e.detail.value;
   	var yuanyin=this.data.array[index];

    this.setData({
      yuanyin:yuanyin,
      index: e.detail.value,
    })
  },

reasonChange:function(e){
    this.setData({
      reason: e.detail.value
    })

},
	 
 
	onLoad: function (options) {

		
		var order_id = options.order_id;
		this.setData({order_id:order_id});
		 
	},
	 
})